﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TV4Home.WebInterface.UI.Code;

namespace TV4Home.WebInterface.UI
{
    public partial class WebSiteMaster : System.Web.UI.MasterPage
    {
        public string PageTitle;

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void Timer1_Tick(object sender, EventArgs e)
        {
            this.Timer1.Enabled = false;

            if (UpdateUI())
                this.ContentPlaceHolderUpdatePanel.Visible = true;
        }

        private bool UpdateUI()
        {
            try
            {
                if (Page is PageBase)
                    (Page as PageBase).UpdateUI();

                return true;
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
                lblError.Visible = true;

                return false;
            }
        }

        public void ReloadUpdatePanel()
        {
            this.ContentPlaceHolderUpdatePanel.Visible = false;
            this.Timer1.Enabled = true;
        }
    }
}
